package com.zzyl.task;

import com.zzyl.nursing.domain.Contract;
import com.zzyl.nursing.service.IContractService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

@Slf4j
@Component
public class SpringTask {
    @Autowired
    private RedisTemplate<Object, Object> redisTemplate;
    @Autowired
    private IContractService contractService;

    @Scheduled(cron = "0 0 1 * * ?")
    public void taskContract() {
        for (Contract contract : contractService.selectContractList(null)) {
            if (contract.getStartDate().isAfter(LocalDateTime.now())) {
                log.info("无效合同！");
                return;
            }
            log.info("有效合同！");
        }

    }
}
